package com.yanqu.road.server.logic.activity.condition.twins;

import com.yanqu.road.entity.activity.ActivityConditionInfo;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.twins.TwinsMissionDamageArgs;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.logic.activity.BaseActivityData;
import com.yanqu.road.server.logic.activity.condition.BaseNewRankActivityCondition;
import com.yanqu.road.server.logic.activity.condition.BaseUserYRankCondition;

import java.math.BigInteger;


public class TwinsPassDamageRankCondition extends BaseUserYRankCondition {

    public TwinsPassDamageRankCondition(ActivityInfo activityInfo, ActivityConditionInfo activityConditionInfo, BaseActivityData baseActivityData) {
        super(activityInfo, activityConditionInfo, baseActivityData);
    }

    @Override
    protected void player_BoardLevelHandle(Object object) {
        TwinsMissionDamageArgs args = (TwinsMissionDamageArgs) object;
        if(args.getValue().compareTo(getValue()) > 0 || new BigInteger(args.getParam()).compareTo(new BigInteger(getParam())) > 0){
            setValue(args.getValue());
            setParam(args.getParam());
            //重新生成排行榜
            rankChange();
        }
    }

    @Override
    public void addTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().addListener(eGamePlayerEventType.TwinsPassDamageRank.getValue(), handle);
    }

    @Override
    public void removeTrigger(GamePlayer player) {
        player.getModule(TaskModule.class).getGameEvent().removeListener(eGamePlayerEventType.TwinsPassDamageRank.getValue(), handle);
    }

}
